<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Encrypt a chunk of data so that it can safely be decrypted in a streaming API</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="function.sodium-crypto-secretstream-xchacha20poly1305-pull.html">« sodium_crypto_secretstream_xchacha20poly1305_pull</a></li>
      <li style="float: right;"><a href="function.sodium-crypto-secretstream-xchacha20poly1305-rekey.html">sodium_crypto_secretstream_xchacha20poly1305_rekey »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="ref.sodium.html">Sodium 函数</a></li>
    <li>Encrypt a chunk of data so that it can safely be decrypted in a streaming API</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="function.sodium-crypto-secretstream-xchacha20poly1305-push" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">sodium_crypto_secretstream_xchacha20poly1305_push</h1>
  <p class="verinfo">(PHP 7 &gt;= 7.2.0, PHP 8)</p><p class="refpurpose"><span class="refname">sodium_crypto_secretstream_xchacha20poly1305_push</span> &mdash; <span class="dc-title">Encrypt a chunk of data so that it can safely be decrypted in a streaming API</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.sodium-crypto-secretstream-xchacha20poly1305-push-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>sodium_crypto_secretstream_xchacha20poly1305_push</strong></span>(<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">string</span> <code class="parameter reference">&$state</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">string</span> <code class="parameter">$message</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">string</span> <code class="parameter">$additional_data</code><span class="initializer"> = &quot;&quot;</span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">int</span> <code class="parameter">$tag</code><span class="initializer"> = <strong><code>SODIUM_CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_TAG_MESSAGE</code></strong></span></span><br>): <span class="type">string</span></div>

  <p class="para rdfs-comment">
   Encrypt a chunk of data so that it can safely be decrypted in a streaming API.
  </p>

 </div>


 <div class="refsect1 parameters" id="refsect1-function.sodium-crypto-secretstream-xchacha20poly1305-push-parameters">
  <h3 class="title">参数</h3>
  <dl>
   
    <dt>
<code class="parameter">state</code></dt>

    <dd>

     <p class="para">
      See <span class="function"><a href="function.sodium-crypto-secretstream-xchacha20poly1305-init-pull.html" class="function">sodium_crypto_secretstream_xchacha20poly1305_init_pull()</a></span>
      and <span class="function"><a href="function.sodium-crypto-secretstream-xchacha20poly1305-init-push.html" class="function">sodium_crypto_secretstream_xchacha20poly1305_init_push()</a></span>
     </p>
    </dd>

   
   
    <dt>
<code class="parameter">message</code></dt>

    <dd>

     <p class="para">
      
     </p>
    </dd>

   
   
    <dt>
<code class="parameter">additional_data</code></dt>

    <dd>

     <p class="para">
      
     </p>
    </dd>

   
   
    <dt>
<code class="parameter">tag</code></dt>

    <dd>

     <p class="para">
      Optional. Can be used to assert decryption behavior
      (i.e. re-keying or indicating the final chunk in a stream).
     </p>
     <ul class="simplelist">
      <li class="member">
       <strong><code>SODIUM_CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_TAG_MESSAGE</code></strong>:
       the most common tag, that doesn&#039;t add any information about the nature of the message.
      </li>
      <li class="member">
       <strong><code>SODIUM_CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_TAG_FINAL</code></strong>:
       indicates that the message marks the end of the stream, and erases the secret key used to encrypt the previous sequence.
      </li>
      <li class="member">
       <strong><code>SODIUM_CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_TAG_PUSH</code></strong>:
       indicates that the message marks the end of a set of messages, but not the end of the stream.
       For example, a huge JSON string sent as multiple chunks can use this tag to indicate to the application that the
       string is complete and that it can be decoded. But the stream itself is not closed, and more data may follow.
      </li>
      <li class="member">
       <strong><code>SODIUM_CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_TAG_REKEY</code></strong>:
       &quot;forget&quot; the key used to encrypt this message and the previous ones, and derive a new secret key.
      </li>
     </ul>
    </dd>

   
  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.sodium-crypto-secretstream-xchacha20poly1305-push-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns the encrypted ciphertext.
  </p>
 </div>



</div></div></div></body></html>